import { BasicColumn, FormSchema } from '/@/components/Table';
import { getDictDetailListApi } from '/@/api/sys/dict';

export const Permission = {
  ADD: 'dict.add',
  EDIT: 'dict.edit',
  DEL: 'dict.del',
};

export const columns: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'title',
  },
  {
    title: '编号',
    dataIndex: 'code',
  },
  {
    title: '默认字典',
    dataIndex: 'defaulted',
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'title',
    label: '标题',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'code',
    label: '编号',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'defaulted',
    label: '默认字典',
    component: 'ApiSelect',
    componentProps: {
      api: getDictDetailListApi,
      params: {
        code: 'defaulted',
      },
    },
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'title',
    label: '标题',
    component: 'Input',
    rules: [
      { required: true, message: '请填写标题' },
      { max: 100, message: '标题最多100字' },
    ],
  },
  {
    field: 'code',
    label: '编号',
    component: 'Input',
    rules: [
      { required: true, message: '请填写编号' },
      { max: 100, message: '编号最多100字' },
    ],
  },
  {
    field: 'defaulted',
    label: '默认字典',
    component: 'ApiRadioGroup',
    defaultValue: 1,
    helpMessage: ['默认字典创建后不能删除且不允许修改编号'],
    componentProps: {
      api: getDictDetailListApi,
      params: {
        code: 'defaulted',
      },
      isBtn: true,
     
    },
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    rules: [{ max: 255, message: '编号最多255字' }],
  },
];
